import { CircleBarButtonItem, CircleBarTableButtonItem } from './types';
import { DEFAULT_MOUSE_GESTURE } from '@app-base/common/providers/const';

// 视图命令
import { cmdFitView } from '@app-cad-env/nextcad/commands/feature/cmd-fit-view';
import {
  cmdRenderAllEdge,
  cmdRenderHiddenEdge,
  cmdRenderNoEdge,
  cmdRenderPhysicalMaterial,
  cmdRenderWireframe,
} from '@app-cad/common/commands/cmd-renderMode';
import {
  cmdPanView,
  cmdRotateView,
  cmdZoomView,
} from '@app-cad/common/commands/cmd-toolbar-mouse-control';
import { cmdResizeToArea } from '@app-base/common/commands/cmd-resize-to-area';
import { cmdPickFace } from '@app-base/common/commands/cmd-pickType';
import { cmdPickLine } from '@app-base/common/commands/cmd-pickType';
import { cmdPickPoint } from '@app-base/common/commands/cmd-pickType';
import { cmdPickModel } from '@app-base/common/commands/cmd-pickType';
import { cmdConstLine } from '@app-cad-env/nextcad/commands/sketch/cmd-const-line';
import { cmdSectionView } from '@app-cad-env/product/commands/cmd-section-view';

// 零件标准命令
import { cmdImport } from '@app-cad/common/commands/cmd-import';
import { cmdExport } from '@app-cad/common/commands/cmd-export';
import { cmdUndo } from '@app-cad/common/commands/cmd-undo';
import { cmdRedo } from '@app-cad/common/commands/cmd-redo';
import { cmdSketchIn } from '@app-cad-env/nextcad/commands/feature/cmd-sketch-in';

// 线框命令
import { cmdPoint } from '@app-cad-env/nextcad/commands/curved/cmd-point';
import { cmdLine } from '@app-cad-env/nextcad/commands/curved/cmd-line';
import { cmdCsys } from '@app-cad/common/commands/cmd-csys';
import { cmdVertexExtremal } from '@app-cad-env/nextcad/commands/curved/cmd-point-extremal';
import { cmdCopyVertex } from '@app-cad-env/nextcad/commands/curved/cmd-copy-vertex';
import { cmdPolyline } from '@app-cad-env/nextcad/commands/curved/cmd-polyline';
import { cmdPlane } from '@app-cad-env/nextcad/commands/curved/cmd-plane';
import { cmdCurveParallel } from '@app-cad-env/nextcad/commands/curved/cmd-curve-parallel';
import { cmdCopyPlane } from '@app-cad-env/nextcad/commands/curved/cmd-copy-plane';
import { cmdArcOfCircle } from '@app-cad-env/nextcad/commands/curved/cmd-arc';
import { cmdFillet } from '@app-cad-env/nextcad/commands/curved/cmd-fillet';
import { cmdSpline } from '@app-cad-env/nextcad/commands/curved/cmd-spline';
import { cmdCurveConic } from '@app-cad-env/nextcad/commands/curved/cmd-curve-conic';
import { cmdCurveIso } from '@app-cad-env/nextcad/commands/curved/cmd-curve-iso';
import { cmdHelix } from '@app-cad-env/nextcad/commands/feature/cmd-helix';
import { cmdLawCurve } from '@app-cad-env/nextcad/commands/curved/cmd-law-curve';
import { cmdBlendCurve } from '@app-cad-env/nextcad/commands/curved/cmd-blend-curve';
import { cmdMatchCurve } from '@app-cad-env/nextcad/commands/curved/cmd-match-curve';
import { cmdCurveHybrid } from '@app-cad-env/nextcad/commands/curved/cmd-curve-hybrid';
import { cmdOffsetCurve } from '@app-cad-env/nextcad/commands/curved/cmd-offest-curve';
import { cmdProjection } from '@app-cad-env/nextcad/commands/curved/cmd-projection';
import { cmdCross2 } from '@app-cad-env/nextcad/commands/curved/cmd-cross2';
import { cmdCurveJoin } from '@app-cad-env/nextcad/commands/curved/cmd-curve-join';
import { cmdSmooth } from '@app-cad-env/nextcad/commands/curved/cmd-smooth';
import { cmdRebuildCurve } from '@app-cad-env/nextcad/commands/curved/cmd-rebuild-curve';
import { cmdCurveBreak } from '@app-cad-env/nextcad/commands/curved/cmd-curve-break';
import { cmdExplode } from '@app-cad-env/nextcad/commands/curved/cmd-explode';
import { cmdExtendCurve } from '@app-cad-env/nextcad/commands/curved/cmd-extend-curve';

// 特征命令
import { cmdExtrudeCut } from '@app-cad-env/nextcad/commands/feature/cmd-extrude/cut';
import { cmdStretch } from '@app-cad-env/nextcad/commands/feature/cmd-extrude/extrude';
import { cmdRevol } from '@app-cad-env/nextcad/commands/feature/cmd-revol';
import { cmdRevolCut } from '@app-cad-env/nextcad/commands/feature/cmd-revol-cut';
import { cmdLoft } from '@app-cad-env/nextcad/commands/feature/cmd-loft';
import { cmdLoftCut } from '@app-cad-env/nextcad/commands/feature/cmd-loft-cut';
import { cmdSweep } from '@app-cad-env/nextcad/commands/feature/cmd-sweep';
import { cmdSweepCut } from '@app-cad-env/nextcad/commands/feature/cmd-sweep-cut';
import { cmdShell } from '@app-cad-env/nextcad/commands/feature/cmd-shell';
import { cmdStiffener } from '@app-cad-env/nextcad/commands/feature/cmd-stiffener';
import { cmdMsolid } from '@app-cad-env/nextcad/commands/curved/cmd-msolid';
import { cmdThickness } from '@app-cad-env/nextcad/commands/feature/cmd-thickness';
import { cmdThicknessCut } from '@app-cad-env/nextcad/commands/feature/cmd-thickness-cut';
import { cmdCutter } from '@app-cad-env/nextcad/commands/feature/cmd-cutter';
import { cmdDraft } from '@app-cad-env/nextcad/commands/feature/cmd-draft';
import { cmdFillet as cmdFeatureFillet } from '@app-cad-env/nextcad/commands/feature/cmd-fillet';
import { cmdChamfer } from '@app-cad-env/nextcad/commands/feature/cmd-chamfer';
import { cmdBox } from '@app-cad-env/nextcad/commands/feature/cmd-box';
import { cmdTube } from '@app-cad-env/nextcad/commands/feature/cmd-tube';
import { cmdSphere } from '@app-cad-env/nextcad/commands/feature/cmd-sphere';
import { cmdCone } from '@app-cad-env/nextcad/commands/feature/cmd-cone';
import { cmdTorus } from '@app-cad-env/nextcad/commands/feature/cmd-torus';
import { cmdCylinder } from '@app-cad-env/nextcad/commands/feature/cmd-cylinder';
import { cmdPyramid } from '@app-cad-env/nextcad/commands/feature/cmd-pyramid/cmd-pyramid';
import { cmdDeleteFace } from '@app-cad-env/nextcad/commands/feature/cmd-delete-face';
import { cmdRepairFace } from '@app-cad-env/nextcad/commands/feature/cmd-repair-face';
import { cmdReplaceFace } from '@app-cad-env/nextcad/commands/feature/cmd-replace-face';
import { cmdSplitFace } from '@app-cad-env/nextcad/commands/feature/cmd-split-face';
import { cmdBoolean } from '@app-cad-env/nextcad/commands/curved/cmd-boolean';
import { cmdSolidMix } from '@app-cad-env/nextcad/commands/feature/cmd-solid-mix';
import { cmdHole } from '@app-cad-env/nextcad/commands/feature/cmd-hole';
import { cmdThread } from '@app-cad-env/nextcad/commands/feature/cmd-thread';

// 曲面命令
import { cmdExtrudeSurface } from '@app-cad-env/nextcad/commands/curved/cmd-extrude-surface';
import { cmdLoftSurface } from '@app-cad-env/nextcad/commands/curved/cmd-loft-surface';
import { cmdFourPointSurface } from '@app-cad-env/nextcad/commands/curved/cmd-four-point-surface';
import { cmdLinearSweep } from '@app-cad-env/nextcad/commands/curved/cmd-linear-sweep';
import { cmdDisplaySweepSurface } from '@app-cad-env/nextcad/commands/curved/cmd-display-sweep-surface';
import { cmdCircularSweep } from '@app-cad-env/nextcad/commands/curved/cmd-circle-sweep';
import { cmdMonorailSweep } from '@app-cad-env/nextcad/commands/curved/cmd-monorail-sweep';
import { cmdDoubleTrackSweep } from '@app-cad-env/nextcad/commands/curved/cmd-double-track-sweep';
import { cmdRevolveSweep } from '@app-cad-env/nextcad/commands/curved/cmd-revolve-sweep';
import { cmdConicalSweep } from '@app-cad-env/nextcad/commands/curved/cmd-curve-conic-sweep';
import { cmdCylinderSurface } from '@app-cad-env/nextcad/commands/feature/cmd-cylinder-surface';
import { cmdSphereSurface } from '@app-cad-env/nextcad/commands/feature/cmd-sphere-surface';
import { cmdFillSurface } from '@app-cad-env/nextcad/commands/curved/cmd-fill-surface';
import { cmdSurfaceTranslation } from '@app-cad-env/nextcad/commands/curved/cmd-surface-translation';
import { cmdBlendSurface } from '@app-cad-env/nextcad/commands/curved/cmd-blend-surface';
import { cmdMatchSurface } from '@app-cad-env/nextcad/commands/curved/cmd-match-surface';
import { cmdMface } from '@app-cad-env/nextcad/commands/curved/cmd-mface';
import { cmdFaceSew } from '@app-cad-env/nextcad/commands/curved/cmd-face-sew';
import { cmdFaceJoin } from '@app-cad-env/nextcad/commands/curved/cmd-face-join';
import { cmdSurfaceSpliter } from '@app-cad-env/nextcad/commands/curved/cmd-surface-splitter';
import { cmdSurfaceTrim } from '@app-cad-env/nextcad/commands/curved/cmd-surface-trim';
import { cmdRotateSurface } from '@app-cad-env/nextcad/commands/curved/cmd-rotate-surface';
import { cmdSurfaceUntrim } from '@app-cad-env/nextcad/commands/curved/cmd-untrim';
import { cmdRebuildSurface } from '@app-cad-env/nextcad/commands/curved/cmd-surface-rebuild';
import { cmdExtendSurface } from '@app-cad-env/nextcad/commands/curved/cmd-extend-surface';
import { cmdExplodeSurface } from '@app-cad-env/nextcad/commands/curved/cmd-explode-surface';
import { cmdRuledCurface } from '@app-cad-env/nextcad/commands/curved/cmd-ruled-surface';

// 变换命令
import { cmdMove } from '@app-cad-env/nextcad/commands/curved/cmd-move';
import { cmdSurfaceRotate as cmdRotate } from '@app-cad-env/nextcad/commands/curved/cmd-rotate';
import { cmdCurveMirror as cmdTransformMirror } from '@app-cad-env/nextcad/commands/curved/cmd-mirror';
import { cmdSetPosition } from '@app-cad-env/nextcad/commands/curved/cmd-set-position';
import { cmdLinearArray as cmdTransformLinearArray } from '@app-cad-env/nextcad/commands/feature/cmd-array-linear';
import { cmdCircularArray as cmdTransformCircularArray } from '@app-cad-env/nextcad/commands/feature/cmd-array-circle';
import { cmdCurveScale } from '@app-cad-env/nextcad/commands/curved/cmd-scale';
import { cmdCurveAffine } from '@app-cad-env/nextcad/commands/curved/cmd-affine';
import { cmdPick } from '@app-cad-env/nextcad/commands/curved/cmd-pick';
import { cmdBoundary } from '@app-cad-env/nextcad/commands/curved/cmd-boundary';
import { cmdInverseSurface } from '@app-cad-env/nextcad/commands/curved/cmd-inverse-surface';

// 工具命令
import { cmdGeomBox } from '@app-cad-env/nextcad/commands/curved/cmd-geom-box';
import { cmdGeomSet } from '@app-cad-env/nextcad/commands/curved/cmd-geom-set';
import { cmdAnalyse } from '@app-cad-env/nextcad/commands/curved/cmd-analyse';
import { cmdCurvatureComb } from '@app-cad-env/nextcad/commands/curved/cmd-curvature-comb';
import { cmdParameterSet } from '@app-cad/common/commands/cmd-parameter-set';
import { cmdParameterObject } from '@app-cad/common/commands/cmd-parameter-object';
import { cmdDesignTable } from '@app-cad/common/commands/cmd-design-table';
import { cmdChangeColor } from '@app-base/common/commands/cmd-change-color';
import { cmdImportAirfoil } from '@app-cad-env/nextcad/commands/feature/cmd-import-airfoilPoints';

// 草图标准命令
import { cmdUndo as cmdSketchUndo } from '@app-cad-env/nextcad/commands/sketch/cmd-undo';
import { cmdRedo as cmdSketchRedo } from '@app-cad-env/nextcad/commands/sketch/cmd-redo';

// 草图命令
import { cmdSketchOut } from '@app-cad-env/nextcad/commands/sketch/cmd-sketch-out';
import {
  cmdArc,
  cmdThreePointArc,
} from '@app-cad-env/nextcad/commands/sketch/cmd-arc';
import { cmdArray } from '@app-cad-env/nextcad/commands/sketch/cmd-array';
import { cmdCircleArray } from '@app-cad-env/nextcad/commands/sketch/cmd-array/circleIndex';
import { cmdChamfer as cmdSketchChamfer } from '@app-cad-env/nextcad/commands/sketch/cmd-chamfer';
import {
  cmdCircle,
  cmdThreeLineCircle,
  cmdThreePointCircle,
} from '@app-cad-env/nextcad/commands/sketch/cmd-circle';
import { cmdConstranit } from '@app-cad-env/nextcad/commands/sketch/cmd-constraint';
import { cmdDivision as cmdSketchDivision } from '@app-cad-env/nextcad/commands/sketch/cmd-division';
import { cmdEllipse } from '@app-cad-env/nextcad/commands/sketch/cmd-ellipse';
import { cmdEllipseArc } from '@app-cad-env/nextcad/commands/sketch/cmd-ellipse-arc';
import { cmdFillet as cmdSketchFillet } from '@app-cad-env/nextcad/commands/sketch/cmd-fillet';
import { cmdLine as cmdSketch2PointLine } from '@app-base/environments/nextcad/commands/sketch/cmd-line/2point';
import { cmdMidPointLine as cmdSketchMidPointLine } from '@app-base/environments/nextcad/commands/sketch/cmd-line/mid-point';
import { cmdMirror as cmdSketchMirror } from '@app-cad-env/nextcad/commands/sketch/cmd-mirror';
import { cmdOffset as cmdSketchOffset } from '@app-cad-env/nextcad/commands/sketch/cmd-offset';
import { cmdPoint as cmdSketchPoint } from '@app-cad-env/nextcad/commands/sketch/cmd-point';
import { cmdMultipleLine as cmdMultipleLine2 } from '@app-cad-env/nextcad/commands/sketch/cmd-polygon';
import {
  cmdCenter,
  cmdDiagonal,
  cmdParallel,
  cmdThreeCenterPoint,
  cmdThreePoint,
} from '@app-cad-env/nextcad/commands/sketch/cmd-rectangle/index';
import { cmdSpline as cmdSketchSpline } from '@app-cad-env/nextcad/commands/sketch/cmd-spline';
import { cmdTrim } from '@app-cad-env/nextcad/commands/sketch/cmd-trim';
import { cmdTangencyArc } from '@app-cad-env/nextcad/commands/sketch/cmd-tangency-arc';
import {
  cmdCenterLineRabbet,
  cmdCenterPointCenterLineRabbet,
} from '@app-cad-env/nextcad/commands/sketch/cmd-center-line-rabbet';
import { Dimintegration } from '@app-cad-env/nextcad/commands/sketch/cmd-integration-dim';
import { cmdIntersect3D } from '@app-cad-env/nextcad/commands/sketch/cmd-intersect-3d';
import {
  cmdCenterPointArcRabbet,
  cmdThreePointArcRabbet,
} from '@app-cad-env/nextcad/commands/sketch/cmd-arc-rabbet';

// 装配标准命令
import { cmdExport as cmdExportProduct } from '@app-cad-env/product/commands/cmd-export';

// 装配命令
import { cmdCircularArray } from '@app-cad-env/product/commands/cmd-array-circle';
import { cmdLinearArray } from '@app-cad-env/product/commands/cmd-array-linear';
import { cmdConstrain } from '@app-cad-env/product/commands/cmd-constrain';
import { cmdConstrainFix } from '@app-cad-env/product/commands/cmd-constrain-fix';
import { cmdCopyPart } from '@app-cad-env/product/commands/cmd-copy';
import { cmdMirror } from '@app-cad-env/product/commands/cmd-mirror';
import { cmdTransformPart } from '@app-cad-env/product/commands/cmd-transform';
import { cmdAddDoc } from '@app-cad-env/product/commands/cmd-add';
import { cmdCopyWithConstraint } from '@app-cad-env/product/commands/cmd-copy-with-constraints';
import { cmdExchangeDoc } from '@app-cad-env/product/commands/cmd-exchange';
import { cmdInsertDoc } from '@app-cad-env/product/commands/cmd-insert';

// 评估命令
import { cmdMeasure } from '@app-cad/common/commands/cmd-measure';
import { cmdInterferenceCheck } from '@app-cad-env/product/commands/cmd-interference-check';
import { cmdHoleAlignCheck } from '@app-cad-env/product/commands/cmd-hole-align-check';
import { cmdIntervalCheck } from '@app-cad-env/product/commands/cmd-interval-check';
import { cmdProject3D } from '@app-base/environments/nextcad/commands/sketch/cmd-project-3d';
import { cmdSketchTransform } from '@app-base/environments/nextcad/commands/sketch/cmd-transform';
import { cmdAirfoil } from '@app-base/environments/nextcad/commands/feature/cmd-create-airfoil';
import { cmdGenerateDrafting } from '@app-base/environments/nextcad/commands/tools/cmd-generate-drafting';

// 视图命令 - 使用懒加载避免循环依赖
const getViewCommands = () => {
  const {
    cmdFrontView,
    cmdBackView,
    cmdLeftView,
    cmdRightView,
    cmdTopView,
    cmdBottomView,
    cmdIsometricView,
    cmdVerticalView,
  } = require('@app-cad/common/commands/cmd-view-classification'); // eslint-disable-line

  return {
    cmdFrontView: {
      cmd: cmdFrontView,
      featureFlag: 'view-classification',
    },
    cmdBackView: {
      cmd: cmdBackView,
      featureFlag: 'view-classification',
    },
    cmdLeftView: {
      cmd: cmdLeftView,
      featureFlag: 'view-classification',
    },
    cmdRightView: {
      cmd: cmdRightView,
      featureFlag: 'view-classification',
    },
    cmdTopView: {
      cmd: cmdTopView,
      featureFlag: 'view-classification',
    },
    cmdBottomView: {
      cmd: cmdBottomView,
      featureFlag: 'view-classification',
    },
    cmdIsometricView: {
      cmd: cmdIsometricView,
      featureFlag: 'view-classification',
    },
    cmdVerticalView: {
      cmd: cmdVerticalView,
      featureFlag: 'view-classification',
    },
  };
};

const cmdViewPickMap = {
  cmdPickModel: {
    cmd: cmdPickModel,
  },
  cmdPickFace: {
    cmd: cmdPickFace,
  },
  cmdPickLine: {
    cmd: cmdPickLine,
  },
  cmdPickPoint: {
    cmd: cmdPickPoint,
  },
};

// 视图控制命令
const cmdViewControlMap = {
  cmdPanView: {
    cmd: cmdPanView,
    featureFlag: 'toolBar-view',
    activated: 'isViewControlActive',
  },
  cmdRotateView: {
    cmd: cmdRotateView,
    featureFlag: 'toolBar-view',
    activated: 'isViewControlActive',
  },
  cmdZoomView: {
    cmd: cmdZoomView,
    featureFlag: 'toolBar-view',
    activated: 'isViewControlActive',
  },
  cmdFitView: {
    cmd: cmdFitView,
  },
  cmdResizeToArea: {
    cmd: cmdResizeToArea,
  },
};

// 视图渲染命令
const cmdViewRenderMap = {
  cmdRenderAllEdge: {
    cmd: cmdRenderAllEdge,
    featureFlag: 'render-mode',
  },
  cmdRenderHiddenEdge: {
    cmd: cmdRenderHiddenEdge,
    featureFlag: 'render-mode',
  },
  cmdRenderNoEdge: {
    cmd: cmdRenderNoEdge,
    featureFlag: 'render-mode',
  },
  cmdRenderWireframe: {
    cmd: cmdRenderWireframe,
    featureFlag: 'render-mode',
  },
  cmdRenderPhysicalMaterial: {
    cmd: cmdRenderPhysicalMaterial,
    featureFlag: 'render-mode',
  },
};

// 视图草图命令
const cmdViewSketchMap = {
  cmdConstLine: {
    cmd: cmdConstLine,
  },
};

// 视图装配命令
const cmdViewAssemblyMap = {
  cmdSectionView: {
    cmd: cmdSectionView,
    featureFlag: 'product-section-view',
  },
  cmdChangeColor: {
    cmd: cmdChangeColor,
    featureFlag: 'change-color',
  },
};

// 零件装配标准命令
const cmdPartAssemblyStandardMap = {
  cmdUndo: {
    cmd: cmdUndo,
  },
  cmdRedo: {
    cmd: cmdRedo,
  },
  cmdGenerateDrafting: {
    cmd: cmdGenerateDrafting,
    featureFlag: 'generate-drafting',
  },
};

// 零件标准命令
const cmdPartStandardMap = {
  cmdImport: {
    cmd: cmdImport,
    featureFlag: 'electron-show-port',
  },
  cmdExport: {
    cmd: cmdExport,
    featureFlag: 'electron-show-port',
  },
  cmdSketchIn: {
    cmd: cmdSketchIn,
  },
};

// 线框命令
const cmdWireframeMap = {
  cmdCsys: {
    cmd: cmdCsys,
  },
  cmdPoint: {
    cmd: cmdPoint,
  },
  cmdVertexExtremal: {
    cmd: cmdVertexExtremal,
  },
  cmdCopyVertex: {
    cmd: cmdCopyVertex,
  },
  cmdLine: {
    cmd: cmdLine,
  },
  cmdPolyline: {
    cmd: cmdPolyline,
    featureFlag: 'polyline',
  },
  cmdPlane: {
    cmd: cmdPlane,
  },
  cmdCurveParallel: {
    cmd: cmdCurveParallel,
    featureFlag: 'cmd-curve-parallel',
  },
  cmdCopyPlane: {
    cmd: cmdCopyPlane,
    featureFlag: 'copy-plane',
  },
  cmdArcOfCircle: {
    cmd: cmdArcOfCircle,
  },
  cmdFillet: {
    cmd: cmdFillet,
  },
  cmdSpline: {
    cmd: cmdSpline,
  },
  cmdCurveConic: {
    cmd: cmdCurveConic,
  },
  cmdCurveIso: {
    cmd: cmdCurveIso,
  },
  cmdHelix: {
    cmd: cmdHelix,
  },
  cmdLawCurve: {
    cmd: cmdLawCurve,
    featureFlag: 'law-curve',
  },
  cmdBlendCurve: {
    cmd: cmdBlendCurve,
  },
  cmdMatchCurve: {
    cmd: cmdMatchCurve,
  },
  cmdCurveHybrid: {
    cmd: cmdCurveHybrid,
  },
  cmdOffsetCurve: {
    cmd: cmdOffsetCurve,
  },
  cmdProjection: {
    cmd: cmdProjection,
  },
  cmdCross2: {
    cmd: cmdCross2,
  },
  cmdCurveJoin: {
    cmd: cmdCurveJoin,
  },
  cmdSmooth: {
    cmd: cmdSmooth,
  },
  cmdRebuildCurve: {
    cmd: cmdRebuildCurve,
  },
  cmdCurveBreak: {
    cmd: cmdCurveBreak,
  },
  cmdExplode: {
    cmd: cmdExplode,
  },
  cmdExtendCurve: {
    cmd: cmdExtendCurve,
  },
};

// 特征命令
const cmdFeatureMap = {
  cmdStretch: {
    cmd: cmdStretch,
  },
  cmdExtrudeCut: {
    cmd: cmdExtrudeCut,
  },
  cmdRevol: {
    cmd: cmdRevol,
  },
  cmdRevolCut: {
    cmd: cmdRevolCut,
  },
  cmdLoft: {
    cmd: cmdLoft,
  },
  cmdLoftCut: {
    cmd: cmdLoftCut,
    featureFlag: 'loft-cut',
  },
  cmdSweep: {
    cmd: cmdSweep,
  },
  cmdSweepCut: {
    cmd: cmdSweepCut,
    featureFlag: 'sweep-cut',
  },
  cmdShell: {
    cmd: cmdShell,
  },
  cmdStiffener: {
    cmd: cmdStiffener,
    featureFlag: 'stiffence',
  },
  cmdMsolid: {
    cmd: cmdMsolid,
  },
  cmdThickness: {
    cmd: cmdThickness,
  },
  cmdThicknessCut: {
    cmd: cmdThicknessCut,
  },
  cmdCutter: {
    cmd: cmdCutter,
  },
  cmdDraft: {
    cmd: cmdDraft,
  },
  cmdFeatureFillet: {
    cmd: cmdFeatureFillet,
  },
  cmdChamfer: {
    cmd: cmdChamfer,
  },
  cmdBox: {
    cmd: cmdBox,
    featureFlag: 'regular-box',
  },
  cmdTube: {
    cmd: cmdTube,
  },
  cmdSphere: {
    cmd: cmdSphere,
    featureFlag: 'regular-sphere',
  },
  cmdCone: {
    cmd: cmdCone,
  },
  cmdTorus: {
    cmd: cmdTorus,
    featureFlag: 'regular-torus',
  },
  cmdCylinder: {
    cmd: cmdCylinder,
    featureFlag: 'regular-cylinder',
  },
  cmdPyramid: {
    cmd: cmdPyramid,
  },
  cmdDeleteFace: {
    cmd: cmdDeleteFace,
    featureFlag: 'delete-face',
  },
  cmdRepairFace: {
    cmd: cmdRepairFace,
    featureFlag: 'repair-face',
  },
  cmdReplaceFace: {
    cmd: cmdReplaceFace,
    featureFlag: 'replace-face',
  },
  cmdSplitFace: {
    cmd: cmdSplitFace,
    featureFlag: 'split-face',
  },
  cmdBoolean: {
    cmd: cmdBoolean,
  },
  cmdSolidMix: {
    cmd: cmdSolidMix,
    featureFlag: 'cmd-solid-mix',
  },
  cmdHole: {
    cmd: cmdHole,
    featureFlag: 'hole',
  },
  cmdThread: {
    cmd: cmdThread,
    featureFlag: 'cmd-thread',
  },
};

// 曲面命令
const cmdSurfaceMap = {
  cmdExtrudeSurface: {
    cmd: cmdExtrudeSurface,
  },
  cmdLoftSurface: {
    cmd: cmdLoftSurface,
  },
  cmdFourPointSurface: {
    cmd: cmdFourPointSurface,
  },
  cmdLinearSweep: {
    cmd: cmdLinearSweep,
  },
  cmdDisplaySweepSurface: {
    cmd: cmdDisplaySweepSurface,
  },
  cmdCircularSweep: {
    cmd: cmdCircularSweep,
  },
  cmdMonorailSweep: {
    cmd: cmdMonorailSweep,
  },
  cmdDoubleTrackSweep: {
    cmd: cmdDoubleTrackSweep,
  },
  cmdRevolveSweep: {
    cmd: cmdRevolveSweep,
  },
  cmdConicalSweep: {
    cmd: cmdConicalSweep,
  },
  cmdCylinderSurface: {
    cmd: cmdCylinderSurface,
    featureFlag: 'cylinder-surface',
  },
  cmdSphereSurface: {
    cmd: cmdSphereSurface,
    featureFlag: 'sphere-surface',
  },
  cmdFillSurface: {
    cmd: cmdFillSurface,
  },
  cmdSurfaceTranslation: {
    cmd: cmdSurfaceTranslation,
  },
  cmdBlendSurface: {
    cmd: cmdBlendSurface,
  },
  cmdMatchSurface: {
    cmd: cmdMatchSurface,
  },
  cmdMface: {
    cmd: cmdMface,
  },
  cmdFaceSew: {
    cmd: cmdFaceSew,
  },
  cmdFaceJoin: {
    cmd: cmdFaceJoin,
  },
  cmdSurfaceSpliter: {
    cmd: cmdSurfaceSpliter,
    featureFlag: 'spliter-surface',
  },
  cmdSurfaceTrim: {
    cmd: cmdSurfaceTrim,
    featureFlag: 'trim-surface',
  },
  cmdRotateSurface: {
    cmd: cmdRotateSurface,
    featureFlag: 'rotate-surface',
  },
  cmdSurfaceUntrim: {
    cmd: cmdSurfaceUntrim,
  },
  cmdRebuildSurface: {
    cmd: cmdRebuildSurface,
  },
  cmdExtendSurface: {
    cmd: cmdExtendSurface,
  },
  cmdExplodeSurface: {
    cmd: cmdExplodeSurface,
  },
  cmdRuledCurface: {
    cmd: cmdRuledCurface,
    featureFlag: 'ruled-curface',
  },
};

// 变换命令
const cmdTransformMap = {
  cmdMove: {
    cmd: cmdMove,
  },
  cmdRotate: {
    cmd: cmdRotate,
  },
  cmdTransformMirror: {
    cmd: cmdTransformMirror,
  },
  cmdSetPosition: {
    cmd: cmdSetPosition,
  },
  cmdTransformLinearArray: {
    cmd: cmdTransformLinearArray,
    featureFlag: 'tools-array-linear',
  },
  cmdTransformCircularArray: {
    cmd: cmdTransformCircularArray,
    featureFlag: 'tools-array-circular',
  },
  cmdCurveScale: {
    cmd: cmdCurveScale,
  },
  cmdCurveAffine: {
    cmd: cmdCurveAffine,
  },
  cmdPick: {
    cmd: cmdPick,
  },
  cmdBoundary: {
    cmd: cmdBoundary,
  },
  cmdInverseSurface: {
    cmd: cmdInverseSurface,
  },
};

// 工具命令
const cmdToolMap = {
  cmdGeomBox: {
    cmd: cmdGeomBox,
  },
  cmdGeomSet: {
    cmd: cmdGeomSet,
    featureFlag: 'cmd-geom-set',
  },
  cmdMeasure: {
    cmd: cmdMeasure,
    featureFlag: 'cmd-measure',
  },
  cmdAnalyse: {
    cmd: cmdAnalyse,
    featureFlag: 'cmd-analyse',
  },
  cmdCurvatureComb: {
    cmd: cmdCurvatureComb,
    featureFlag: 'cmd-curvature-comb',
  },
  cmdParameterSet: {
    cmd: cmdParameterSet,
    featureFlag: 'cmd-parameter',
  },
  cmdParameterObject: {
    cmd: cmdParameterObject,
    featureFlag: 'cmd-parameter',
  },
  cmdDesignTable: {
    cmd: cmdDesignTable,
    featureFlag: 'cmd-design-table',
  },
  cmdChangeColor: {
    cmd: cmdChangeColor,
  },
};

// 插件命令
const cmdPluginMap = {
  cmdImportAirfoil: {
    cmd: cmdImportAirfoil,
    featureFlag: 'cmd-import-airfoilPoints',
  },
  cmdCreateAirfoil: {
    cmd: cmdAirfoil,
    featureFlag: 'cmd-create-airfoil',
  },
};

// 草图标准命令
const cmdSketchStandardMap = {
  cmdSketchUndo: {
    cmd: cmdSketchUndo,
  },
  cmdSketchRedo: {
    cmd: cmdSketchRedo,
  },
};

// 草图命令
const cmdSketchMap = {
  cmdSketchOut: {
    cmd: cmdSketchOut,
  },
  cmdSketchPoint: {
    cmd: cmdSketchPoint,
  },
  cmdCircle: {
    cmd: cmdCircle,
  },
  cmdThreePointCircle: {
    cmd: cmdThreePointCircle,
    featureFlag: 'three-point-circle',
  },
  cmdEllipse: {
    cmd: cmdEllipse,
  },
  cmdEllipseArc: {
    cmd: cmdEllipseArc,
    featureFlag: 'ellipse-arc',
  },
  cmdArc: {
    cmd: cmdArc,
  },
  cmdThreePointArc: {
    cmd: cmdThreePointArc,
    featureFlag: 'three-point-arc',
  },
  cmdTangencyArc: {
    cmd: cmdTangencyArc,
  },
  cmdLine2: {
    cmd: cmdSketch2PointLine,
  },
  cmdSketchMidPointLine: {
    cmd: cmdSketchMidPointLine,
  },
  cmdMultipleLine2: {
    cmd: cmdMultipleLine2,
  },
  cmdDiagonal: {
    cmd: cmdDiagonal,
  },
  cmdCenter: {
    cmd: cmdCenter,
  },
  cmdParallel: {
    cmd: cmdParallel,
  },
  cmdThreePoint: {
    cmd: cmdThreePoint,
  },
  cmdThreeLineCircle: {
    cmd: cmdThreeLineCircle,
  },
  cmdThreeCenterPoint: {
    cmd: cmdThreeCenterPoint,
    featureFlag: 'three-point-center-rectangle',
  },
  cmdCenterLineRabbet: {
    cmd: cmdCenterLineRabbet,
    featureFlag: 'center-line-rabbet',
  },
  cmdCenterPointCenterLineRabbet: {
    cmd: cmdCenterPointCenterLineRabbet,
    featureFlag: 'center-point-center-line-rabbet',
  },
  cmdThreePointArcRabbet: {
    cmd: cmdThreePointArcRabbet,
    featureFlag: 'three-point-arc-rabbet',
  },
  cmdCenterPointArcRabbet: {
    cmd: cmdCenterPointArcRabbet,
    featureFlag: 'center-point-arc-rabbet',
  },
  cmdSketchSpline: {
    cmd: cmdSketchSpline,
  },
  cmdSketchMirror: {
    cmd: cmdSketchMirror,
  },
  cmdTrim: {
    cmd: cmdTrim,
  },
  cmdSketchFillet: {
    cmd: cmdSketchFillet,
  },
  cmdSketchChamfer: {
    cmd: cmdSketchChamfer,
  },
  cmdSketchDivision: {
    cmd: cmdSketchDivision,
  },
  cmdSketchOffset: {
    cmd: cmdSketchOffset,
  },
  cmdArray: {
    cmd: cmdArray,
  },
  cmdCircleArray: {
    cmd: cmdCircleArray,
  },
  cmdConstranit: {
    cmd: cmdConstranit,
  },
  Dimintegration: {
    cmd: Dimintegration,
    featureFlag: 'dimensional-constraint',
  },
  cmdSketchTransform: {
    cmd: cmdSketchTransform,
  },
  cmdIntersect3D: {
    cmd: cmdIntersect3D,
    featureFlag: 'sketch-intersect3d',
  },
  cmdProject3D: {
    cmd: cmdProject3D,
    featureFlag: 'sketch-project-3d',
  },
};

// 装配标准命令
const cmdAssemblyStandardMap = {
  cmdExportProduct: {
    cmd: cmdExportProduct,
    featureFlag: 'product-export',
  },
};

// 装配命令
const cmdAssemblyMap = {
  cmdInsertDoc: {
    cmd: cmdInsertDoc,
    featureFlag: 'product-insert',
  },
  cmdAddDoc: {
    cmd: cmdAddDoc,
    featureFlag: 'product-add',
  },
  cmdExchangeDoc: {
    cmd: cmdExchangeDoc,
    featureFlag: 'product-exchange',
  },
  cmdCopyPart: {
    cmd: cmdCopyPart,
    featureFlag: 'product-copy',
  },
  cmdLinearArray: {
    cmd: cmdLinearArray,
    featureFlag: 'product-linear-array',
  },
  cmdCircularArray: {
    cmd: cmdCircularArray,
    featureFlag: 'product-circular-array',
  },
  cmdMirror: {
    cmd: cmdMirror,
    featureFlag: 'product-mirror',
  },
  cmdCopyWithConstraint: {
    cmd: cmdCopyWithConstraint,
    featureFlag: 'product-copy-with-constraints',
  },
  cmdConstrainFix: {
    cmd: cmdConstrainFix,
    featureFlag: 'product-constrain-fix',
  },
  cmdConstrain: {
    cmd: cmdConstrain,
    featureFlag: 'product-constrain',
  },
  cmdTransformPart: {
    cmd: cmdTransformPart,
    featureFlag: 'product-transform',
  },
  cmdProductPlane: {
    cmd: cmdPlane,
    featureFlag: 'product-plane',
  },
  cmdProductCSys: {
    cmd: cmdCsys,
    featureFlag: 'product-csys',
  },
};

// 评估命令
const cmdEvaluationMap = {
  cmdInterferenceCheck: {
    cmd: cmdInterferenceCheck,
    featureFlag: 'product-interference-check',
  },
  cmdIntervalCheck: {
    cmd: cmdIntervalCheck,
    featureFlag: 'product-interval-check',
  },
  cmdHoleAlignCheck: {
    cmd: cmdHoleAlignCheck,
    featureFlag: 'product-hole-align-check',
  },
  cmdMeasure: {
    cmd: cmdMeasure,
    featureFlag: 'product-measure',
  },
};

// 获取命令映射
const getCmdMap = () => {
  const viewCommands = getViewCommands();
  return {
    ...viewCommands,
    ...cmdViewPickMap,
    ...cmdViewControlMap,
    ...cmdViewRenderMap,
    ...cmdPartAssemblyStandardMap,
    ...cmdViewSketchMap,
    ...cmdViewAssemblyMap,

    ...cmdPartStandardMap,
    ...cmdWireframeMap,
    ...cmdFeatureMap,
    ...cmdSurfaceMap,
    ...cmdTransformMap,
    ...cmdToolMap,
    ...cmdPluginMap,
    ...cmdSketchStandardMap,
    ...cmdSketchMap,

    ...cmdAssemblyStandardMap,
    ...cmdAssemblyMap,
    ...cmdEvaluationMap,
  };
};
export const circleBarButtons = (
  env: string = 'part_env',
  buttons: string[] = [],
) => {
  if (!buttons || buttons.length === 0) {
    // 如果没有提供按钮，使用默认配置
    buttons = DEFAULT_MOUSE_GESTURE[env];
  }
  const cmdMap = getCmdMap();
  return buttons.map((button) => ({
    name: button,
    cmd: cmdMap[button]?.cmd,
    featureFlag: cmdMap[button]?.featureFlag,
    activated: cmdMap[button]?.activated,
  })) as CircleBarButtonItem[];
};

export const getTableButtonList = (
  omitViewer: boolean = false,
): CircleBarTableButtonItem[] => [
  // 视图命令
  ...(omitViewer
    ? []
    : Object.entries(cmdViewControlMap).map(([key, btn]) => ({
        id: btn.cmd.id,
        environment: ['part_env', 'sketch_env', 'product_env'],
        type: 'settings.view',
        name: key,
        label: btn.cmd?.label,
        icon: btn.cmd?.icon,
        featureFlag: (btn as any)?.featureFlag,
      }))),
  ...(omitViewer
    ? []
    : Object.entries(getViewCommands()).map(([key, btn]) => ({
        id: btn.cmd.id,
        environment: ['part_env', 'sketch_env', 'product_env'],
        type: 'settings.view',
        name: key,
        label: btn?.cmd?.label,
        icon: btn?.cmd?.icon,
        featureFlag: (btn as any)?.featureFlag,
      }))),
  ...(omitViewer
    ? []
    : Object.entries(cmdViewRenderMap).map(([key, btn]) => ({
        id: btn.cmd.id,
        environment: ['part_env', 'sketch_env'],
        type: 'settings.view',
        name: key,
        label: btn.cmd?.label,
        icon: btn.cmd?.icon,
        featureFlag: (btn as any)?.featureFlag,
      }))),
  ...(omitViewer
    ? []
    : Object.entries(cmdViewPickMap).map(([key, btn]) => ({
        id: btn.cmd.id,
        environment: ['part_env', 'sketch_env'],
        type: 'settings.view',
        name: key,
        label: btn?.cmd?.label,
        icon: btn?.cmd?.icon,
        featureFlag: (btn as any)?.featureFlag,
      }))),
  ...Object.entries(cmdViewSketchMap).map(([key, btn]) => ({
    id: btn.cmd.id,
    environment: ['sketch_env'],
    type: 'settings.view',
    name: key,
    label: btn.cmd?.label,
    icon: btn.cmd?.icon,
    featureFlag: (btn as any)?.featureFlag,
  })),
  ...(omitViewer
    ? []
    : Object.entries(cmdViewAssemblyMap).map(([key, btn]) => ({
        id: btn.cmd.id,
        environment: ['product_env'],
        type: 'settings.view',
        name: key,
        label: btn.cmd?.label,
        icon: btn.cmd?.icon,
        featureFlag: (btn as any)?.featureFlag,
      }))),
  // 零件装配标准命令
  ...Object.entries(cmdPartAssemblyStandardMap).map(([key, btn]) => ({
    id: btn.cmd.id,
    environment: ['part_env', 'product_env'],
    type: 'settings.standard',
    name: key,
    label: btn?.cmd?.label,
    icon: btn?.cmd?.icon,
    featureFlag: (btn as any)?.featureFlag,
  })),
  // 零件命令
  ...Object.entries(cmdPartStandardMap).map(([key, btn]) => ({
    id: btn.cmd.id,
    environment: ['part_env'],
    type: 'settings.standard',
    name: key,
    label: btn?.cmd?.label,
    icon: btn?.cmd?.icon,
    featureFlag: (btn as any)?.featureFlag,
  })),
  ...Object.entries(cmdWireframeMap).map(([key, btn]) => ({
    id: btn.cmd.id,
    environment: ['part_env'],
    type: 'settings.wireframe',
    name: key,
    label: btn?.cmd?.label,
    icon: btn?.cmd?.icon,
    featureFlag: (btn as any)?.featureFlag,
  })),
  ...Object.entries(cmdFeatureMap).map(([key, btn]) => ({
    id: btn.cmd.id,
    environment: ['part_env'],
    type: 'settings.feature',
    name: key,
    label: btn?.cmd?.label,
    icon: btn?.cmd?.icon,
    featureFlag: (btn as any)?.featureFlag,
  })),
  ...Object.entries(cmdSurfaceMap).map(([key, btn]) => ({
    id: btn.cmd.id,
    environment: ['part_env'],
    type: 'settings.surface',
    name: key,
    label: btn?.cmd?.label,
    icon: btn?.cmd?.icon,
    featureFlag: (btn as any)?.featureFlag,
  })),
  ...Object.entries(cmdTransformMap).map(([key, btn]) => ({
    id: btn.cmd.id,
    environment: ['part_env'],
    type: 'settings.transform',
    name: key,
    label: btn?.cmd?.label,
    icon: btn?.cmd?.icon,
    featureFlag: (btn as any)?.featureFlag,
  })),
  ...Object.entries(cmdToolMap).map(([key, btn]) => ({
    id: btn.cmd.id,
    environment: ['part_env'],
    type: 'settings.tool',
    name: key,
    label: btn?.cmd?.label,
    icon: btn?.cmd?.icon,
    featureFlag: (btn as any)?.featureFlag,
  })),
  ...Object.entries(cmdPluginMap).map(([key, btn]) => ({
    id: btn.cmd.id,
    environment: ['part_env'],
    type: '插件',
    name: key,
    label: btn?.cmd?.label,
    icon: btn?.cmd?.icon,
    featureFlag: (btn as any)?.featureFlag,
  })),
  // 草图命令
  ...Object.entries(cmdSketchStandardMap).map(([key, btn]) => ({
    id: btn.cmd.id,
    environment: ['sketch_env'],
    type: 'settings.standard',
    name: key,
    label: btn?.cmd?.label,
    icon: btn?.cmd?.icon,
    featureFlag: (btn as any)?.featureFlag,
  })),
  ...Object.entries(cmdSketchMap).map(([key, btn]) => ({
    id: btn.cmd.id,
    environment: ['sketch_env'],
    type: 'settings.sketch',
    name: key,
    label: btn?.cmd?.label,
    icon: btn?.cmd?.icon,
    featureFlag: (btn as any)?.featureFlag,
  })),
  // 装配命令
  ...Object.entries(cmdAssemblyStandardMap).map(([key, btn]) => ({
    id: btn.cmd.id,
    environment: ['product_env'],
    type: 'settings.standard',
    name: key,
    label: btn?.cmd?.label,
    icon: btn?.cmd?.icon,
    featureFlag: (btn as any)?.featureFlag,
  })),
  ...Object.entries(cmdAssemblyMap).map(([key, btn]) => ({
    id: btn.cmd.id,
    environment: ['product_env'],
    type: 'settings.assembly',
    name: key,
    label: btn?.cmd?.label,
    icon: btn?.cmd?.icon,
    featureFlag: (btn as any)?.featureFlag,
  })),
  ...Object.entries(cmdEvaluationMap).map(([key, btn]) => ({
    id: btn.cmd.id,
    environment: ['product_env'],
    type: 'settings.evaluation',
    name: key,
    label: btn?.cmd?.label,
    icon: btn?.cmd?.icon,
    featureFlag: (btn as any)?.featureFlag,
  })),
];
